package my_annotation.demo2;

import java.lang.reflect.Method;

public class Test {
    public static void main(String[] args) throws Exception {
        Class<?> clazz = Class.forName("my_annotation.demo2.Animal");
        Object o = clazz.getDeclaredConstructor(String.class, int.class, String.class).newInstance("🐘", 5, "🍌");
        Method[] declaredMethods = clazz.getDeclaredMethods();
        for (Method method : declaredMethods) {
            if (method.isAnnotationPresent(Anno.class)) {
                Anno anno = method.getAnnotation(Anno.class);
                System.out.println(anno);
                Method eat = clazz.getDeclaredMethod(anno.method());
                System.out.println(eat);
                eat.invoke(o);
            }
        }
    }
}
